using System;
using System.Collections.Generic;
using System.Text;
using ARR.Entities.ComponentModel;
using System.Runtime.Serialization;
using System.Linq.Expressions;

namespace ARR.Entities.Validation.Common
{
    public delegate bool ValidationDelegate();

    [DataContract]
    [Serializable]
    public class CustomValidation : ValidationBase
    {

        private ValidationDelegate _validationDelegate;
        
        public CustomValidation(string propertyName, string brokenDescription, ValidationDelegate validationDelegate) : base(propertyName, brokenDescription)
        {
            this.ValidationDelegate = validationDelegate;
        }

        

        [DataMember]
        protected virtual ValidationDelegate ValidationDelegate
        {
            get { return _validationDelegate; }
            set { _validationDelegate = value; }
        }


        public override bool Validate(ValidatableEntity domainObject)
        {
            return ValidationDelegate();
        }
    }
}
